package com.demo.timer;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

/**
 * FileName: DiffTest.java
 * 类的详细说明
 *
 * @author Pretty_Boy
 * @version 1.00
 * @Date 2018/9/2910:23
 */
public class DiffTest {

    public static void main(String[] args) {
        //获取当前时间
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String now = format.format(calendar.getTime());
        System.out.println("当前时间====>>>" + now);

        //获取当前6秒后的日期
        calendar.add(Calendar.SECOND,-6);
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("scheduleExecutionTime====》》》" + format.format(this.scheduledExecutionTime()));
            }
        },calendar.getTime(),2000);

    }
}
